<template>
    <el-dialog v-if="dialogVisible" :close-on-click-modal='false' title="基础信息" :visible.sync="dialogVisible"
        @close="resetForm('editVideoBaseSzRef')" width="400px">
        <el-form label-position="top" label-width="auto" size="medium" :hide-required-asterisk='true'
            :model="editVideoBaseSzForm" :rules="editVideoBaseSzRules" ref="editVideoBaseSzRef" v-loading="loading">
            <el-form-item label="截止日期" prop="closing_date">
                <el-select v-model="editVideoBaseSzForm.closing_date" filterable placeholder="请选择截止日期" style="width:100%">
                    <el-option :label="item.nickname" :value="item.id" v-for="item in dataList" :key="item.id"></el-option>
                    <!-- <el-option label="周二" :value="2"></el-option>
                    <el-option label="周三" :value="3"></el-option>
                    <el-option label="周四" :value="4"></el-option>
                    <el-option label="周五" :value="5"></el-option>
                    <el-option label="周六" :value="6"></el-option>
                    <el-option label="周日" :value="7"></el-option>
                    <el-option label="移至下周" :value="8"></el-option> -->
                </el-select>
            </el-form-item>
            <el-form-item label="需求信息" prop="description" style="margin-bottom:0">
                <el-input type="textarea" :rows="3" placeholder="请输入需求信息" v-model="editVideoBaseSzForm.description">
                </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="resetForm('editVideoBaseSzRef')" class="el-button-width" size="small">取 消</el-button>
            <el-button type="primary" @click="submitForm('editVideoBaseSzRef')" class="el-button-width" size="small"
                :disabled='disabled' :loading="disabled">提 交</el-button>
        </span>
    </el-dialog>
</template>

<script>
export default {
    props:["dataList"],
    name: "",
    data() {
        return {
            disabled: false,
            dialogVisible: false,
            editVideoBaseSzForm: {
                id: "",
                closing_date: "",
                description: "",
            },
            editVideoBaseSzRules: {
                closing_date: [
                    {
                        required: true,
                        message: "请选择截止日期",
                        trigger: "blur",
                    },
                ],
            },
        };
    },

    created() {
        
    },
    methods: {
        // 提交添加
        submitForm(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    this.submitJust()
                } else {
                    this.disabled = false;
                    return false;
                }
            });
        },

        async submitJust() {
            this.disabled = true;
            const { data: res } = await this.$http.post(
                "adminapi/Demandszv2/videoEditBase",
                this.editVideoBaseSzForm
            );
            if (res.code !== 200) {
                this.disabled = false;
                this.$message.error(res.msg);
                return;
            } else {
                this.$message({
                    message: "提交成功",
                    type: "success",
                });
                this.disabled = false;
                this.resetForm('editVideoBaseSzRef');
                this.$parent.getDataList(this.$parent.queryInfo.page);
            }
        },


        // 关闭重置表单
        resetForm(formName) {
            this.$refs[formName].resetFields();
            this.dialogVisible = false;
        },
    },
};
</script>
<style scoped>
.sche_info {
    font-size: 14px;
    color: #616c85;
    background-color: rgba(165, 177, 209, 0.08);
    border-radius: 12px;
    padding: 12px;
}

.sche_info li {
    height: 36px;
}

.sche_text {
    color: #17233d;
}
</style>

